/** 存储内容 */

const userTokenKey = 'userTokenKey';
const userInfoKey = 'userInfoKey';
const routeKey = 'routeKey';
const guidKey = 'guidKey';
const menuKey = 'menuKey';

export function putAccessToken(token:string) {
  localStorage.setItem(userTokenKey, token);
}

export function getAccessToken() {
  let str : string | null = localStorage.getItem(userTokenKey);
  if (str) {
    return str;
  }
  return null;
}

export function putUserInfo(userObj:any) {
  const value =  JSON.stringify(userObj);
  localStorage.setItem(userInfoKey, value);
}

export function getUserInfo() {
  let str : string | null = localStorage.getItem(userInfoKey);
  if (str) {
    return JSON.parse(<string>str);
  }
  return null;
}

export function getGuidList() {
  let str : string | null = localStorage.getItem(guidKey);
  if (str) {
    return JSON.parse(str);
  }
  return null;
}

export function setGuidList(list:string[]) {
  const value =  JSON.stringify(list);
  localStorage.setItem(guidKey, value);
}


export function getRouteCache() {
  let str : string | null = localStorage.getItem(routeKey);
  if (str) {
    return JSON.parse(str);
  }
  return null;
}

export function setRouteCache(menuList:any) {
  const value =  JSON.stringify(menuList);
  localStorage.setItem(routeKey, value);
}


export function getMenuCache() {
  let str : string | null = localStorage.getItem(menuKey);
  if (str) {
    return JSON.parse(str);
  }
  return null;
}

export function setMenuCache(menuList:any) {
  const value =  JSON.stringify(menuList);
  localStorage.setItem(menuKey, value);
}

